
//刷新
function loadDate(){
	grid_ae.loadServerData();
	contentList.length = 0;
}
//得到域名
var evn_Path = getPath();
function getPath() {
	//var envPath = document.location.pathname;
	var protoStr = document.location.protocol;
	var hostStr = document.location.host;
	var portStr = document.location.port;
	//var envPathArray = envPath.split('/');
	return protoStr + "//" + hostStr + "/";
}
/**
 * 
 */
Date.prototype.format = function(format) {
	/*
	 * eg:format="YYYY-MM-dd hh:mm:ss";
	 */
	var o = {
		"M+" : this.getMonth() + 1, // month
		"d+" : this.getDate(), // day
		"h+" : this.getHours(), // hour
		"m+" : this.getMinutes(), // minute
		"s+" : this.getSeconds(), // second
		"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
		"S" : this.getMilliseconds()
	// millisecond
	}

	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	}

	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
					: ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;
}
//
function IsNull(i) {
	return (i == null || i == 'null' || i == '' || i == 'undefined');
}
/**
 * 地址的操作
 * author 
 * @param provinceId		省/直辖市的ID
 * @param cityId		城市/直辖市的区
 * @param countyId		县/直辖市的街道
 * @param townId		镇
 */
function initProvince(provinceId, cityId, countyId, townId) {
	$.get(evn_Path + "getProvince.htm", function(data) {
		$("#" + provinceId).html("<option value='0'>请选择</option>");
		$("#" + cityId).html("<option value='0'>请选择</option>");
		$("#" + countyId).html("<option value='0'>请选择</option>");
		$("#" + townId).html("<option value='0'>请选择</option>");
		$.each(data, function(i) {
			$("#" + provinceId).append(
					"<option value='" + data[i].province + "'>" + data[i].value
							+ "</option>");
		});
	}, 'json');
	$("#" + provinceId).change(
			function() {
				$.get(evn_Path + "getCity.htm?provinceId="
						+ $("#" + provinceId).val(), function(data) {
					$("#" + cityId).html("<option value='0'>请选择</option>");
					$("#" + countyId).html("<option value='0'>请选择</option>");
					$("#" + townId).html("<option value='0'>请选择</option>");
					$.each(data, function(i) {
						$("#" + cityId).append(
								"<option value='" + data[i].city + "'>"
										+ data[i].value + "</option>");
					});
				}, 'json');
			});

	$("#" + cityId).change(
			function() {
				$.get(evn_Path + "getCounty.htm?cityId="
						+ $("#" + cityId).val(), function(data) {
					$("#" + countyId).html("<option value='0'>请选择</option>");
					$("#" + townId).html("<option value='0'>请选择</option>");
					$.each(data, function(i) {
						$("#" + countyId).append(
								"<option value='" + data[i].county + "'>"
										+ data[i].value + "</option>");
					});
				}, 'json');
			});

	$("#" + countyId).change(
			function() {
				$.get(evn_Path + "getTown.htm?countyId="
						+ $("#" + countyId).val(), function(data) {
					$("#" + townId).html("<option value='0'>请选择</option>");
					$.each(data, function(i) {
						$("#" + townId).append(
								"<option value='" + data[i].town + "'>"
										+ data[i].value + "</option>");
					});
				}, 'json');
			});
}

function provinceChange(provinceId, cityId, countyId, townId, provinceValue,
		cityValue, countyValue, townValue) {
	$.get(evn_Path + "getProvince.htm", function(data) {
		$("#" + provinceId).html("<option value='0'>请选择</option>");
		$("#" + cityId).html("<option value='0'>请选择</option>");
		$("#" + countyId).html("<option value='0'>请选择</option>");
		$("#" + townId).html("<option value='0'>请选择</option>");
		$.each(data, function(i) {
			if (data[i].province == provinceValue) {
				$("#" + provinceId).append(
						"<option selected value='" + data[i].province + "'>"
								+ data[i].value + "</option>");
			} else {
				$("#" + provinceId).append(
						"<option value='" + data[i].province + "'>"
								+ data[i].value + "</option>");
			}

		});
		//////////////////
			$.get(evn_Path + "getCity.htm?provinceId=" + provinceValue,
					function(data) {
						$("#" + cityId).html("<option value='0'>请选择</option>");
						$("#" + countyId)
								.html("<option value='0'>请选择</option>");
						$("#" + townId).html("<option value='0'>请选择</option>");
						$.each(data, function(i) {
							if (data[i].city == cityValue) {
								$("#" + cityId).append(
										"<option selected value='"
												+ data[i].city + "'>"
												+ data[i].value + "</option>");
							} else {
								$("#" + cityId).append(
										"<option value='" + data[i].city + "'>"
												+ data[i].value + "</option>");
							}

						});
						//////////////
					$.get(evn_Path + "getCounty.htm?cityId=" + cityValue,
							function(data) {
								$("#" + countyId).html(
										"<option value='0'>请选择</option>");
								$("#" + townId).html(
										"<option value='0'>请选择</option>");
								$.each(data, function(i) {
									if (data[i].county == countyValue) {
										$("#" + countyId).append(
												"<option selected value='"
														+ data[i].county + "'>"
														+ data[i].value
														+ "</option>");
									} else {
										$("#" + countyId).append(
												"<option value='"
														+ data[i].county + "'>"
														+ data[i].value
														+ "</option>");
									}

								});
								///////////////
							$.get(evn_Path + "getTown.htm?countyId="
									+ countyValue, function(data) {
								$("#" + townId).html(
										"<option value='0'>请选择</option>");
								$.each(data, function(i) {
									if (data[i].town == townValue) {
										$("#" + townId).append(
												"<option selected value='"
														+ data[i].town + "'>"
														+ data[i].value
														+ "</option>");
									} else {
										$("#" + townId).append(
												"<option value='"
														+ data[i].town + "'>"
														+ data[i].value
														+ "</option>");
									}

								});
							}, 'json');
							//////////////
						}, 'json');
					///////////
				}, 'json');
			/////////////////
		}, 'json');

	$("#" + provinceId).change(
			function() {
				$.get(evn_Path + "getCity.htm?provinceId="
						+ $("#" + provinceId).val(), function(data) {
					$("#" + cityId).html("<option value='0'>请选择</option>");
					$("#" + countyId).html("<option value='0'>请选择</option>");
					$("#" + townId).html("<option value='0'>请选择</option>");
					$.each(data, function(i) {
						$("#" + cityId).append(
								"<option value='" + data[i].city + "'>"
										+ data[i].value + "</option>");
					});
				}, 'json');
			});

	$("#" + cityId).change(
			function() {
				$.get(evn_Path + "getCounty.htm?cityId="
						+ $("#" + cityId).val(), function(data) {
					$("#" + countyId).html("<option value='0'>请选择</option>");
					$("#" + townId).html("<option value='0'>请选择</option>");
					$.each(data, function(i) {
						$("#" + countyId).append(
								"<option value='" + data[i].county + "'>"
										+ data[i].value + "</option>");
					});
				}, 'json');
			});

	$("#" + countyId).change(
			function() {
				$.get(evn_Path + "getTown.htm?countyId="
						+ $("#" + countyId).val(), function(data) {
					$("#" + townId).html("<option value='0'>请选择</option>");
					$.each(data, function(i) {
						$("#" + townId).append(
								"<option value='" + data[i].town + "'>"
										+ data[i].value + "</option>");
					});
				}, 'json');
			});
}
/*自定义JS*/

$('.icon_date').hover(
 function(){
  $('.tooltipi').fadeIn();
 }
);

$('.icon_date').mousemove(function(e){
 var top = e.pageY+5;
 var left = e.pageX+5;
 $('.tooltipi').css({
  'top' : top + 'px',
  'left': left+ 'px'
 });
});

$('.icon_date').mouseout(function(){
 $('.tooltipi').hide();
});
//上传图片
function uploadCmsImg(self) {
	var filepath = $(self).val();
	var extStart = filepath.lastIndexOf(".");
	var ext = filepath.substring(extStart, filepath.length).toUpperCase();
	if (ext != ".PNG" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
		alert("图片限于png,jpeg,jpg,gif格式");
		return;
	}
	$(self).parent().ajaxSubmit(
			{
				dataType : 'json',
				cache : false,
				success : function(data) {
					var parentId=$(self).attr("id");
					$(self).parent().find("img:first").attr("src",data.imageServer + data.imageUrl);
					$("#imageWidth"+parentId).val(data.width);
					$("#imageHeight"+parentId).val(data.height);
				},
				error : function(err) {
					alert(err);
				}
			});
	return false;
}
	ART = {
		checkLogin : function(){
			var isLogin = false;
			$.ajax({
				type:"post",
				async:false, //同步
				url: "/member/checklogin.htm",
				success:function(data){
					if(data=='logged'){
						isLogin = true;
					}
				}
			});
			return isLogin;	
		},
		keepPic:function(picId){
			if(ART.checkLogin()){
				$.get("/artHas.htm?picId="+picId+"&owner=keep"+"&type=room",function(data){
					if(data=="alreadyLove"){
						alert("你已经收藏过了");
					}else if(data == "loveSuccess"){
						alert("收藏成功");
					}
				}); 
			}else{
				alert("请登录~");
				window.location.href="login.htm"
			}
		},
		lovePic:function(picId){
			if(ART.checkLogin()){
				$.get("/artHas.htm?picId="+picId+"&owner=love"+"&type=auction",function(data){
					if(data=="alreadyLove"){
						alert("你已经关注过了");
					}else if(data == "loveSuccess"){
						alert("关注成功");
					}
				}); 
			}else{
				alert("请登录~");
				window.location.href="login.htm"
			}
		},
		lookPic:function(picId){
			if(ART.checkLogin()){
				$.get("/artHas.htm?picId="+picId+"&owner=look"+"&type=find",function(data){
					if(data=="alreadyLove"){
						alert("你已经欣赏过了");
					}else if(data == "loveSuccess"){
						alert("欣赏成功");
					}
				}); 
			}else{
				alert("请登录~");
				window.location.href="login.htm"
			}
		},
		likeArtArtist:function(artistId){
			if(ART.checkLogin()){
				$.get("/likeArtArtist.htm?artistId="+artistId,function(data){
					if(data=="alreadyLove"){
						alert("你已经关注过了");
					}else if(data == "likeSuccess"){
						alert("关注成功");
					}
				}); 
			}else{
				alert("请登录~");
				window.location.href="login.htm"
			}
		}
	}
	function fart(id){
		window.location.href="fart.htm?id="+id;
	}
	function buyArt(id){
		if(ART.checkLogin()){
			window.location.href="buyArt.htm?id="+id;
		}else{
			alert("请登录~");
			window.location.href="login.htm"
		}
	}
	//等比例图片
	function loadImage(obj, boxWidth, boxHeight) {
		        var tempImg = new Image();    
		        var thumbID = $(obj).attr("id");
		        tempImg.src =  $("#"+thumbID).attr("src");
		       
		        var imgWidth=tempImg.width;  
		        var imgHeight=tempImg.height;  
		        if((boxWidth/boxHeight)>=(imgWidth/imgHeight))  
		        {  
		        	$("#"+thumbID).width((boxHeight*imgWidth)/imgHeight);  
		        	$("#"+thumbID).height(boxHeight);  
		            var margin=(boxWidth-$("#"+thumbID).width())/2;  
		            $("#"+thumbID).css("margin-left",margin);  
		        }  
		        else  
		        {  
		        	$("#"+thumbID).width(boxWidth);  
		        	$("#"+thumbID).height((boxWidth*imgHeight)/imgWidth);  
		            var margin=(boxHeight-$("#"+thumbID).height())/2;  
		            $("#"+thumbID).css("margin-top",margin);  
		        }  
	    } 
	
	
